import React, { Component } from 'react';
import {  Swiper } from 'antd-mobile'
import { user_banner } from '../../utils/api'
class MySwiper extends Component {
    constructor(props) {
        super(props)
        this.state = {
            bannerlist: []
        }
    }

    componentDidMount() {
        user_banner().then((res) => {
            if (res.data.code === 200) {
                
                this.setState({
                    bannerlist: res.data.list
                })

            }
        })
    }

    render() {
        return (
            <div className='myswiper'>
                <Swiper autoplay loop>
                    {
                        this.state.bannerlist.map((item,index)=>{
                            return (
                                <Swiper.Item key={index}>
                                    <img src={item.pic} alt="" />
                                </Swiper.Item>
                            )
                        })
                    }
                </Swiper>
                
            </div>
        );
    }
}

export default MySwiper;